-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add cds logger #93
Conversation
@zongqichen @swennemers @Fannon : A logging is added to the ORD Plugin. For logging is re-used the logger @sap/cds. |
Hi @aramovic79 , I agree to have only two levels, but the levels are the others. My opinion is level INFO and ERROR are important. When you debug or monitor logs in production env, INFO and ERROR can provide clear message to people who look into it. When I debug in dev env, the DEBUG level logger can't support me more than debug mode in vscode. Based on my experience, I always ignore warning message, since for me the program is either succeed or failed. So we need ERROR level message which can wake up admin at night shift when the program broke out. |
…t-add-logger-to-handle-errors
Please check here how the log levels are enumerated in cap cds(the lower number => the higher severity). This is here-implemented logging setup: In dev environment, the DEBUG level is set to some truthy value(in .cdsrc.json or by setting DEBUG env. variable), which results in showing in console(or log file or ...) all of the following logs:
In production, the default level is WARNING, which means that only the following logs will be shown:
@zongqichen : Is your proposal to set default level in production to be ERROR(so to "consider" only the |
My proposal is even simpler. We don't need to distinguish dev or production environment, we only use INFO and ERROR when it is really necessary. It will keep our code and console clean. And I visit other repos in cap-js, there are quite mix, some repo use debug and warn like cds-typer, some don't use at all like change-tracking. My preference is the second one. However, I don't strong opinion on it, what do you think @swennemers @Fannon ? |
Hi @aramovic79 , I forget to mention it, could you revisit all codes and replace all, console.error, console.info or new Error with logger? If you think it's out of the scope, you could raise an new issue for it. Thx |
Done as requested. Also, the issue #86 is fixed in this PR as well, since it was partially related to the logging. Could you please take a look? Thank you! |
Hi @aramovic79 , thank you for replacing console log. There is still a small issue need to be adjust, https://cap.cloud.sap/docs/node.js/cds-log#recommendations. The construct format message in logger will be expensive for production env. The best practice is always use |
Good point. Changed as proposed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thx, it looks way better now
No description provided.